/** Add X-Forwarded-Proto to the Vary and X-Vary-Options headers for API
* requests and RSS/Atom feeds. Use this if you have an SSL termination setup
- * and need to split the cache between HTTP and HTTPS for API and feed requests
- * in order to prevent cache pollution. This does not affect 'normal' requests.
+ * and need to split the cache between HTTP and HTTPS for API requests,
+ * feed requests and HTTP redirect responses in order to prevent cache
+ * pollution. This does not affect 'normal' requests to index.php other than
+ * HTTP redirects.
*/
-$wgVaryOnXFPForAPI = false;
+$wgVaryOnXFP = false;
/**
* Internal server name as known to Squid, if different. Example:
* but can also be called separately.
*/
public function httpHeaders() {
- global $wgOut, $wgVaryOnXFPForAPI;
+ global $wgOut, $wgVaryOnXFP;
# We take over from $wgOut, excepting its cache header info
$wgOut->disable();
$mimetype = $this->contentType();
header( "Content-type: $mimetype; charset=UTF-8" );
- if ( $wgVaryOnXFPForAPI ) {
+ if ( $wgVaryOnXFP ) {
$wgOut->addVaryHeader( 'X-Forwarded-Proto' );
}
$wgOut->sendCacheControl();
* the object, let's actually output it:
*/
public function output() {
- global $wgLanguageCode, $wgDebugRedirects, $wgMimeType;
+ global $wgLanguageCode, $wgDebugRedirects, $wgMimeType, $wgVaryOnXFP;
if( $this->mDoNothing ) {
return;
}
$this->mLastModified = wfTimestamp( TS_RFC2822 );
}
+ if ( $wgVaryOnXFP ) {
+ $this->addVaryHeader( 'X-Forwarded-Proto' );
+ }
$this->sendCacheControl();
$response->header( "Content-Type: text/html; charset=utf-8" );
}
protected function sendCacheHeaders() {
- global $wgUseXVO, $wgOut, $wgVaryOnXFPForAPI;
+ global $wgUseXVO, $wgOut, $wgVaryOnXFP;
$response = $this->getRequest()->response();
if ( $this->mCacheMode == 'private' ) {
}
if ( $this->mCacheMode == 'anon-public-user-private' ) {
- $xfp = $wgVaryOnXFPForAPI ? ', X-Forwarded-Proto' : '';
+ $xfp = $wgVaryOnXFP ? ', X-Forwarded-Proto' : '';
$response->header( 'Vary: Accept-Encoding, Cookie' . $xfp );
if ( $wgUseXVO ) {
- if ( $wgVaryOnXFPForAPI ) {
+ if ( $wgVaryOnXFP ) {
$wgOut->addVaryHeader( 'X-Forwarded-Proto' );
}
$response->header( $wgOut->getXVO() );
}
// Send public headers
- if ( $wgVaryOnXFPForAPI ) {
+ if ( $wgVaryOnXFP ) {
$response->header( 'Vary: Accept-Encoding, X-Forwarded-Proto' );
if ( $wgUseXVO ) {
// Bleeeeegh. Our header setting system sucks